home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / archiver / huff_sc.zip / README.TXT < prev    next >
Text File  |  1991-04-25  |  4KB  |  106 lines

  1. readme.txt                                              April 25, 1991
  2.  
  3.  
  4. Huffman compression code compressor and decompressor in Borland C++ 2.0
  5. by Shaun Case, April 1991
  6.  
  7. Enclosed in this archive are two C programs that implement Huffman code
  8. compression.
  9.  
  10. huf.c   <--- compress a file using huffman compression
  11. unhuf.c <--- decompress a file compressed with huf.c
  12.  
  13. Both programs, their source code and executable code, are in the public
  14. domain.  You may use either in any way you want.  You can sell them, use
  15. them in your own pd, freeware, shareware, or commercial application,
  16. without fee, licsence, or royalty of any kind.  You don't even have to
  17. put my name on it, if you don't want to, although that would be a nice
  18. touch.
  19.  
  20. You should know two things before using these programs:
  21.  
  22. 1)  I am completely unresponsible for any liability arising from use of
  23. these programs, either in executable or source form.  They are for use
  24. as-is, without any kind of waranty or guarantee, including but not
  25. limited to FITNESS FOR A PARTICULAR PURPOSE, or merchantability, or
  26. whatever the hell it is.  If you use these program, you assume all
  27. liability.  Use of these programs is acceptance of assumption of
  28. any and all liability, and of the complete freedom of legal
  29. responsibility for damages of any nature, including a large malevolent,
  30. rabid fruit bat flying into your hair in the night and chewing a hole in
  31. your neck, of the author.
  32.  
  33. 2)  There are much better compression schemes available, notably LZW,
  34. and possibly RLE, depending on your data.  LZW, RLE, and this Huffman
  35. implementation are lossless, and are typically not suitable for
  36. compressing digital video in real time.
  37.  
  38. That aside, I'd like to say a few things about the source code:
  39.  
  40. 1)  The compressor is non-optimal in several ways:
  41.     -- the compressed filesize estimation is broken
  42.     -- it uses floating point
  43.     -- it is full of unnecessary code
  44.     -- there are a couple of easy optimizations that could be made
  45.     -- it uses global variables
  46.     -- there is a function call for every character processed.
  47.  
  48.     One of the reasons it is in this condition is that, for my
  49.     application, the data was only going to be compressed once, but
  50.     uncompressed repeatedly.  So, if the compressor was a little
  51.     un-optimal, that was fine.
  52.  
  53. 2)  It works, as far as I can tell, perfectly.  It's bound to have a few
  54.     bugs in it somewhere, but it seems to work with:
  55.     -- pretty large files (~600k)
  56.     -- files that contain no characters
  57.     -- files that contain less than all 256 characters.
  58.  
  59. 3) The original filename is stored in the *.huf file, and is used when
  60.    recreating the original file.
  61.  
  62. 4) It was written in Borland C++.  If you want to compile using another
  63.    compiler, especially one that isn't native to MS-DOS, have fun.  The
  64.    huf program writes out some shorts and a long or two binarily,
  65.    whatever byte ordering your machine normally uses, so data is
  66.    typically not interchangable.  If you are running on a Motorola
  67.    processor, or on a Vax, you will need to fix the byte ordering if you
  68.    want files to be interchangeable with files created under MS-DOS.
  69.  
  70. 5) It was written in a 132 X 43 column SVGA mode, so it may look funny
  71.    if you try to edit it on your 80X25 setup, or try to print it on an
  72.    80 column printer.
  73.  
  74. 6) Datafile format:
  75.  
  76.  
  77.  All 16/32 bit quantities in Intel format
  78.  
  79.  13 bytes    : original filename (8.3 + "\0")
  80.  16 bits     : number of array elements needed, N (N == 511 means 512 array
  81.                elements -> 0..511)
  82.  32 bits     : size of uncompressed original data in bytes
  83.  N * 6 bytes : Array elements in order 0 .. N
  84.                struct decode_table_element {
  85.                     char letter;      8 bits
  86.                     char spare;       8 bits
  87.                     short left;      16 bits
  88.                     short right;     16 bits
  89.                 }
  90. <?>           : compressed data, effectively a bit stream
  91.  
  92.  
  93. I will not be supporting this software, but if you wish to contact me, you
  94. may reach me by email at one of the following addresses:
  95.  
  96. Internet : atman%ecst.csuchico.edu@RELAY.CS.NET
  97. Fidonet  : Shaun Case of 1:119/666.0
  98. WWIVnet  : 1@9651
  99.  
  100. I hope you find this code useful or informative, or maybe both.
  101.  
  102.  
  103. -- Shaun
  104.  
  105.  
  106.